/*
 * bsp_msgqueue.h
 *
 *  Created on: 2025年4月10日
 *      Author: lds
 */
#ifndef __BSP_MSGQUEUE_H__
#define __BSP_MSGQUEUE_H__

/* include */
#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>
#include <stdint.h>
#include <unistd.h>
#include <sys/time.h>
#include <errno.h>
#include "net_protocol.h"

/* define */
#define     MSG_QUEUE_SIZE      100     // 消息队列容量


/* typedef */
#pragma pack(1)
// 消息队列列表节点
typedef struct __message_node 
{
    uint8_t  data[32768];
    struct __message_node   *next;

}message_node;

typedef struct __message_queue
{
    pthread_mutex_t mutex;
    pthread_cond_t  cond_not_empty;
    pthread_cond_t  cond_not_full;
    message_node    *head;
    message_node    *tail;
    int             count;
    int             max_size;

}message_queue;

#pragma pack()


/* global varibles */
extern message_queue g_track_info_queue;
extern message_queue g_dsp_info_queue;

/* private function */

/* function */
extern uint32_t queue_init(message_queue *queue);
extern void queue_destroy(message_queue *queue);
extern uint32_t add_to_queue(const void *p_msg_info, uint32_t len, message_queue *queue);
extern message_node *take_out_from_queue(message_queue *queue);



#endif
